package com.lei.zjs.web.action;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.lei.zjs.service.ebi.FunctionService;
import com.lei.zjs.utils.BOSContext;
import com.lei.zjs.vo.Function;
import com.lei.zjs.vo.User;
import com.lei.zjs.web.action.base.BaseAction;

/**
 * 权限管理Action
 * @author Spinacia
 *
 */
@Controller
@Scope("prototype")
public class FunctionAction extends BaseAction<Function>{

	@Resource
	private FunctionService functionService;
	
	//查询所有权限数据
	public String list() throws IOException{
		List<Function> list = functionService.findAll();
		
		String[] excludes = new String[]{"parentFunction","children","roles"};
		this.writeJsonArray2String(list, excludes );
		return NONE;
	}
	
	//保存权限
	public String save(){
		functionService.save(model);
		return "list";
	}
	
	//加载基本菜单
	public String listMenu() throws IOException{
		User user = BOSContext.getLoginUser();
		List<Function> list = functionService.findMenu(user);
		String[] excludes = new String[]{"parentFunction","children","roles"};
		this.writeJsonArray2String(list, excludes );
		return NONE;
	}
}
